package com.blacktry.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.blog.Articles;
import com.blacktry.entity.model.Vo.BlogVo;
import com.blacktry.entity.model.request.ArticleLabelRequest;
import com.blacktry.entity.model.request.ArticlesRequest;
import com.blacktry.entity.model.vueVO.ArticleVo;
import com.blacktry.mapper.blog.ArticlesMapper;
import com.blacktry.service.ArticlesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author blackTry
 * @since 2022-02-07
 */

//
@Service
public class ArticlesServiceImpl extends ServiceImpl<ArticlesMapper, Articles> implements ArticlesService {
    @Autowired
    ArticlesMapper articlesMapper;
    @Override
    public ArticleVo[] selectHotArticle() {
        return articlesMapper.selectHotArticle();
    }

    @Override
    public ArticleVo[] selectArticleByUserName(String userId) {
        return articlesMapper.selectArticleByUserName(userId);
    }

    @Override
    public Page<ArticleLabelRequest> selectArticles(ArticlesRequest articlesRequest, Page<Articles> articlesPage) {
        return this.baseMapper.selectArticles(articlesRequest, articlesPage);
    }

    @Override
    public int deleteArticle(Integer articleId) {
        return this.baseMapper.deleteById(articleId);
    }

    @Override
    public Articles selectArticleById(Integer articleId) {
        return this.baseMapper.selectById(articleId);
    }

    @Override
    public int updateArticleByArticleId(Articles article) {
        return this.baseMapper.updateById(article);
    }

    @Override
    public List<BlogVo> findAllForES() {
        return this.baseMapper.findAllForES();
    }
}
